package ynu.edu.model.domain;

import lombok.Data;
import ynu.edu.model.entity.HanziGeneration;

import java.time.LocalDateTime;

/**
 * 汉字生成响应DTO
 */
@Data
public class HanziGenerationResponse {

    /**
     * 记录ID
     */
    private Long id;

    /**
     * 汉字字符
     */
    private String chineseChar;

    /**
     * 生成步数
     */
    private Integer steps;

    /**
     * 生成状态
     */
    private String status;

    /**
     * OSS存储的图片URL
     */
    private String ossUrl;

    /**
     * 生成耗时（毫秒）
     */
    private Long generationTime;

    /**
     * 错误信息
     */
    private String errorMessage;

    /**
     * 请求ID
     */
    private String requestId;

    /**
     * 创建时间
     */
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    private LocalDateTime updateTime;

    /**
     * 从实体类转换为响应DTO
     */
    public static HanziGenerationResponse fromEntity(HanziGeneration entity) {
        if (entity == null) {
            return null;
        }
        
        HanziGenerationResponse response = new HanziGenerationResponse();
        response.setId(entity.getId());
        response.setChineseChar(entity.getChineseChar());
        response.setSteps(entity.getSteps());
        response.setStatus(entity.getStatus());
        response.setOssUrl(entity.getOssUrl());
        response.setGenerationTime(entity.getGenerationTime());
        response.setErrorMessage(entity.getErrorMessage());
        response.setRequestId(entity.getRequestId());
        response.setCreateTime(entity.getCreateTime());
        response.setUpdateTime(entity.getUpdateTime());
        
        return response;
    }
} 